<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta charset="UTF-8">
<link href="${pageContext.request.contextPath}/jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-1.11.1-min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
	<script>
		$(function (){
			//将浏览器页面添加一个键盘事件
			$(window).keydown(function (event){
				//13代表enter键在键盘的编码
				if(event.keyCode==13){
					//制造一次单击时间
					$("#login_form").click();
				}
			});
			$("#login_form").click(function (){
				var login_act = $.trim($("#login_act").val());
				var login_pwd = $.trim($("#login_pwd").val());
				var isRember = $("#isRember").prop("checked");
				if(login_act==""){
					return;
				}
				if (login_pwd==""){
					return;
				}
				$.ajax({
					beforeSend:function (){
						$("#msg").css("color","green");
						$("#msg").html("正在努力加载中.......");
						return true;
					},
					url:"${pageContext.request.contextPath}/user/findOne",
					data:{
						login_pwd:login_pwd,
						login_act:login_act,
						isRember:isRember
					},
					type:"post",
					dataType:"json",
					success:function (data){
						if(data.errorCode=="0"){
							$("#msg").css("color","red");
							$("#msg").html(data.errorMessage);
						}else{
							window.location.href="${pageContext.request.contextPath}/index/toIndex";
						}
					}
				});
			});
		})
	</script>
</head>
<body>
	<div style="position: absolute; top: 0px; left: 0px; width: 60%;">
		<img src="${pageContext.request.contextPath}/image/IMG_7114.JPG" style="width: 100%; height: 90%; position: relative; top: 50px;">
	</div>
	<div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
		<div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">&copy;2019&nbsp;动力节点</span></div>
	</div>
	<div style="position: absolute; top: 120px; right: 100px;width:450px;height:400px;border:1px solid #D5D5D5">
		<div style="position: absolute; top: 0px; right: 60px;">
			<div class="page-header">
				<h1>登录</h1>
			</div>
			<form action="${pageContext.request.contextPath}/WEB-INF/pages/workbench/index.jsp" class="form-horizontal" role="form">
				<div class="form-group form-group-lg">
					<div style="width: 350px;">
						<input class="form-control" type="text" value="${cookie.loginAct.value}" id="login_act" placeholder="用户名">
					</div>
					<div style="width: 350px; position: relative;top: 20px;">
						<input class="form-control" type="password" value="${cookie.loginPwd.value}" id="login_pwd" placeholder="密码">
					</div>
					<div class="checkbox"  style="position: relative;top: 30px; left: 10px;">
						<label>
							<c:if test="${not empty cookie.loginAct and not empty cookie.loginPwd}">
							<input id="isRember" type="checkbox" checked> 十天内免登录
							</c:if>
							<c:if test="${empty cookie.loginAct or empty cookie.loginPwd}">
								<input id="isRember" type="checkbox"> 十天内免登录
							</c:if>
						</label>
						&nbsp;&nbsp;
						<span id="msg"></span>
					</div>
					<button type="button" id="login_form" class="btn btn-primary btn-lg btn-block"  style="width: 350px; position: relative;top: 45px;">登录</button>
				</div>
			</form>
		</div>
	</div>
</body>
</html>